
export let MixinsEvent = {
    methods: {
        triggerEvent(eventName, args) {
            // var findKey = this.widget.key;
            // var events = this.findEvent(window.FasFmData.list, findKey);

            var events = this.element.Events;

            var findEvent = _.find(events || [], (eventItem) => {
                return (
                    eventItem.Name &&
                    eventItem.Name.toLowerCase() == eventName.toLowerCase()
                );
            });
            if (false === eventName.toLowerCase().includes("mouse")) {
                // console.info(
                //   this.options.instanceCode,
                //   eventName,
                //   findEvent ? findEvent : "未绑定"
                // );
            }

            if (findEvent && findEvent.ActionType != -1) {
                if (window.TeldFasRTUtils && window.TeldFasRTUtils.trigger) {
                    return window.TeldFasRTUtils.trigger.trigger(findEvent);
                    // debugger;
                } else {
                    alert("当前环境无法触发事件执行上下文");
                    return;
                }
            }
        },
        triggerEventHandler(eventName, args, immediate) {
            if (immediate) {
                return Promise.resolve(this.triggerEvent.apply(this, [eventName, ...(args || [])]));
            } else {
                return new Promise((resolve) => {
                    this.$nextTick(() => {
                        resolve(this.triggerEvent.apply(this, [eventName, ...(args || [])]))
                    });
                });
            }
        },
        FireEvent(eventName) {
           return this.triggerEventHandler(eventName);
        },
    }
}